//订单筛选页面
//时间的
var calendarDateFormat = myApp.calendar({
    input: '#beginTime',
     monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#endTime',
	 monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#deliStartTime',
	 monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#deliEndTime',
	 monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#arrStartTime',
	 monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#arriEndTime',
	 monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var RoleID=$.cookie("RoleID");
(function(){
	var orderFilter={
		init:function(){
			myApp.showIndicator();
			args = GetUrlParms();				
			if(args["type"]!=undefined){
				TYPE=args["type"];
			}

			this.loadParams();
            this.bindEvents();
			SalesLoad();//业务列表
			PurchasesLoad();//采购列表
		    LoadOrderStatusNumber();//订单类型个数
			if(TYPE==1){
				searchDiaParm(); //搜索参数
			}			
		},
		bindEvents:function(){
			var self=this;
			//订单状态的选中
			$("#OrderStatus span").on("click",function(){
				$(this).addClass("active").siblings().removeClass("active");
			});
			//参数的选中
			$("#order_term_box").on("click",".term span",function(){
				$(this).toggleClass("active").siblings().removeClass("active");
			});
			//重置
			$("#reset_btn").on("click",function(){
				$(".term span").removeClass("active");
				$("#order_term_box input").val("");
				
			});
			//确定
			$("#confirm_btn").on("click",function(){
				var orderJson={};
            	orderJson.orderParams = self.getParameters();
            	var orderUrl;
            	if(TYPE==1){
            		orderUrl="/Team/Order";
            	}if(TYPE==2){
            		orderUrl="/Team/ParcelOrder?type=parcels";
            	}else if(TYPE==3){
            		orderUrl="/Team/RingOrder?type=rings";
            	}else if(TYPE==4){
            		orderUrl="/Team/GemOrder?type=gems";
            	}else if(TYPE==5){
            		orderUrl="/Team/EmeraldOrder?type=emeralds";
            	}else if(TYPE==6){
            		orderUrl="/Team/PrimeGoldOrder?type=golds";
            	}else if(TYPE==7){
                    orderUrl="/Team/InlaySettingsOrder?type=inlaysettings";
				}
	            if(APP){
	            	var appJson={};
	            	appJson.title=_("订单");
	            	appJson.url=app_url+orderUrl;
	            	appJson.content=JSON.stringify(orderJson);
	            	YiYi_APP.submitOrder(JSON.stringify(appJson))
	            }else{
	            	var action=orderUrl;
				  	form = $("<form method='post' id='params_form' action='"+action+"'>"+
				   	"<input type='text' value='"+JSON.stringify(orderJson)+"' name='params'></form>")
					$("#form_box").html(form);
					$("#params_form").submit();
	            }
			});

			//订单筛选条件
			var orderList=localStorage.getItem('orderList') || '';
			if(orderList){
				self.oldOrderSelect(orderList);
			}
			
		},
		//获取筛选参数
        getParameters: function () {
        	var requestOrder = {};

		        requestOrder.SalesUserID = $("#_salesUserID").val();
		   
		    //采购员4
		    if (RoleID == 4) {
		        requestOrder.PurchaseUserID = UserID;
		    }
		    else {
		        requestOrder.PurchaseUserID = $("#_purchaseUserIDs").val();
		    }
		    var ordehtml=$("#OrderStatus").find("span.active").html();
			$("#choose_orderstatus").html(ordehtml);
		    requestOrder.PageSize = 200;
		    requestOrder.PageIndex = 1;
		    requestOrder.OrderStatus = $("#OrderStatus").find("span.active").attr("data-value");//订单状态

		    if(TYPE==1){
		    	//原货号		    	
		    	 //以空格间隔开，传数组 原货号
				if ($("#goodsNum").val() != ""){  //为空的话不要这个参数
					var OriginSNVal = trimStr($("#goodsNum").val());
					requestOrder.OriginSN =OriginSNVal; 
				}  	
			   
		    	requestOrder.PaymentStatus = $("#PaymentStatus").find("span.active").attr("data-value");//支付状态
		    	requestOrder.SCreateTime = $("#beginTime").val();//下单开始时间
			    requestOrder.ECreateTime = $("#endTime").val();//下单结束时间
			   
		    }else{
		    	requestOrder.OriginSN=$.trim($("#goodsNum").val());//原货号
		    	requestOrder.ReceiptStatus=$("#PaymentStatus").find("span.active").attr("data-value");//支付状态
		    	// requestOrder.SAddTime = $("#beginTime").val();//下单开始时间
				// requestOrder.EAddTime = $("#endTime").val();//下单结束时间
				if($("#beginTime").val() != "") {
					requestOrder.SAddTime = $("#beginTime").val() + " 00:00:00"; //start_time 开始下单时间
				} else {
					requestOrder.SAddTime = $("#beginTime").val(); //start_time 开始下单时间
				}
				if($("#endTime").val() != "") {
					requestOrder.EAddTime = $("#endTime").val() + " 23:59:59"; //end_time 结束下单时间 2016-12-31 00:00:00 成2016-12-31 23:59:59
				} else {
					requestOrder.EAddTime = $("#endTime").val(); //end_time 结束下单时间 2016-12-31 00:00:00 成2016-12-31 23:59:59
				}		    	
		    }		
//		    requestOrder.StartTime = $("#deliStartTime").val();// 开始发货时间
//		    requestOrder.EndTime = $("#deliEndTime").val();//结束发货时间
		    if($("#deliStartTime").val() != "") {
				requestOrder.StartTime = $("#deliStartTime").val() + " 00:00:00"; //startArrival_time 开始出货时间
			} else {
				requestOrder.StartTime = $("#deliStartTime").val(); //startArrival_time 开始出货时间
			}
			if($("#deliEndTime").val() != "") {
				requestOrder.EndTime = $("#deliEndTime").val() + " 23:59:59"; //endShip_time 结束出货时间  
			} else {
				requestOrder.EndTime = $("#deliEndTime").val(); //endShip_time 结束出货时间  
			}
		    // requestOrder.SArrivalTime = $("#arrStartTime").val();//开始到货时间
			// requestOrder.EArrivalTime = $("#arriEndTime").val();//结束到货时间
			if($("#arrStartTime").val() != "") {
				requestOrder.SArrivalTime = $("#arrStartTime").val() + " 00:00:00"; //startArrival_time 开始到货时间
			} else {
				requestOrder.SArrivalTime = $("#arrStartTime").val(); //startArrival_time 开始到货时间
			}
		
			if($("#arriEndTime").val() != "") {
				requestOrder.EArrivalTime = $("#arriEndTime").val() + " 23:59:59"; //endArrival_time 结束到货时间
			} else {
				requestOrder.EArrivalTime = $("#arriEndTime").val(); //endArrival_time 结束到货时间
			}
		    requestOrder.CurType = $("#_curtype").find("span.active").attr("data-value");;//结算币种 
		    requestOrder.CustomerNickName = $.trim($("#_customerCs").val());//客户昵称
		    requestOrder.CustomerRealName = $.trim($("#customerName").val());//客户名字
		    requestOrder.ShipNo = $("#billNo").val();//出货单号 
		    requestOrder.Weight = $("#weightValue").val();//重量
			if(TYPE==3){
				requestOrder.MainCertNo = $.trim($("#certNo").val());//证书号
				
				requestOrder.MainColor = $("#Color").find("span.active").text();//颜色
		    	requestOrder.MainClarity = $("#Clarity").find("span.active").text();//净度
		   		requestOrder.MainCertType = $("#CertType").find("span.active").text();//证书类型
			}else{
				 //证书号
				if ($("#certNo").val()!= ""){  //为空的话不要这个参数
			        var CertNoVal = trimStr($("#certNo").val());
			        requestOrder.CertNo=CertNoVal;        
			    }
				requestOrder.Color = $("#Color").find("span.active").text();//颜色
		    	requestOrder.Clarity = $("#Clarity").find("span.active").text();//净度
		    	requestOrder.CertType = $("#CertType").find("span.active").text();//证书类型
			}
		   
		    requestOrder.OrderType = $("#orderType").find("span.active").attr('data-value');//订单类型
		    requestOrder.SupplierCode = $("#_supplierCs").val();//供应商 
		    requestOrder.PurchaseSupplier = $("#_PurchaseSupplier").val();//原供应商
		    requestOrder.Color = $("#_Color").val(); //颜色
			requestOrder.Clarity = $("#_Clarity").val(); //净度
			requestOrder.Place = $("#_Place").val();  //所在地
			requestOrder.Status = $("#_orderStatus").val(); //状态：在库、实验室、报关......

			//订单筛选
			//localStorage.setItem('orderList',JSON.stringify(requestOrder));
		   
		    return requestOrder;
        },

		//恢复订单筛选条件选中
        oldOrderSelect: function (data){
            var oldOrderData=JSON.parse(data);
            $('#order_term_box').find('div').find('span').removeClass('active');
            for(var name in oldOrderData){ //遍历对象属性名
            	if(name=='OrderStatus'){ //订单状态
            		$("#order_term_box").find("#OrderStatus").find('span[data-value="'+oldOrderData[name]+'"]').addClass('active');
				}
                if(name=='PaymentStatus' || name=="ReceiptStatus"){ //支付状态
                    $("#order_term_box").find("#PaymentStatus").find('span[data-value="'+oldOrderData[name]+'"]').addClass('active');
                }
                if(name=='OriginSN'){ //原货号
                    $("#goodsNum").val(oldOrderData.OriginSN);
                }
                if(name=='CertNo'){ //证书号
                    $("#certNo").val(oldOrderData.CertNo);
                }
                if(name=='CustomerNickName'){ //客户
                    $("#_customerCs").val(oldOrderData.CustomerNickName);
                }
                if(name=='ShipNo'){ //出货单
                    $("#billNo").val(oldOrderData.ShipNo);
                }
                if(name=='Color'){ //颜色
					setTimeout(function () {
                        $('body #_Color').val(oldOrderData.Color)
                    },10);
                }
                if(name=='Status'){
					$("#_orderStatus").val(oldOrderData.Status)
				}

                if(name=='SupplierCode'){ //供应商
                    $("#_supplierCs").val(oldOrderData.SupplierCode);
                }
                if(name=='PurchaseSupplier'){ //原供应商
                    $("#_PurchaseSupplier").val(oldOrderData.PurchaseSupplier);
                }
                if(name=='SCreateTime'&&oldOrderData.SCreateTime){ //下单日期 开始时间
					$("#beginTime").val(YearDateFormats(oldOrderData.SCreateTime?oldOrderData.SCreateTime:''))
				}
                if(name=='ECreateTime'&&oldOrderData.ECreateTime){ //下单日期 结束时间
                    $("#endTime").val(YearDateFormats(oldOrderData.ECreateTime?oldOrderData.ECreateTime:''))
                }
                if(name=='StartTime'&&oldOrderData.StartTime){ //出货日期 开始时间
                    $("#deliStartTime").val(YearDateFormats(oldOrderData.StartTime?oldOrderData.StartTime:''))
                }
                if(name=='EndTime'&&oldOrderData.EndTime){ //出货日期 结束时间
                    $("#deliEndTime").val(YearDateFormats(oldOrderData.EndTime?oldOrderData.EndTime:''))
                }
                if(name=='SArrivalTime'&&oldOrderData.SArrivalTime){ //到货日期 开始时间
                    $("#arrStartTime").val(YearDateFormats(oldOrderData.SArrivalTime?oldOrderData.SArrivalTime:''))
                }
                if(name=='EArrivalTime'&&oldOrderData.EArrivalTime){ //到货日期 结束时间
                    $("#arriEndTime").val(YearDateFormats(oldOrderData.EArrivalTime?oldOrderData.EArrivalTime:''))
                }
                if(name=='CurType'){ //结算币种
                    $("#order_term_box").find("#_curtype").find('span[data-value="'+oldOrderData[name]+'"]').addClass('active');
				}
                if(name=='OrderType'){ //订单类型
                    var _orderType='';
					if(oldOrderData[name]=='客下'){
                        _orderType=1;
					}else if(oldOrderData[name]=='代下'){
                        _orderType=2;
					}else if(oldOrderData[name]=='录单'){
                        _orderType=3;
					}else if(oldOrderData[name]=='二级'){
                        _orderType=4;
					}
                    $("#order_term_box").find("#orderType").find('span[data-value="'+_orderType+'"]').addClass('active');
                }
			}
		},

		loadParams:function(){
			if(TYPE==1){
				var jsonType=stock;				
			}else if(TYPE==2){
				var jsonType=parcel;	
				//大小
				var size=[
					'<div class="term">',
	                    '<h4>'+_("大小")+'</h4>',
	                    '<span data-value="0.001-0.009">'+_("厘石")+'</span>',
	                    '<span data-value="0.01-0.02">'+_("分石")+'</span>',
	                    '<span data-value="0.03-0.07">0.05</span>',
	                    '<span data-value="0.08-0.12">0.10</span>',
	                    '<span data-value="0.13-0.17">0.15</span>',
	                    '<span data-value="0.18-0.22">0.20</span>',
	                    '<span data-value="0.23-0.29">0.25</span>',
	                    '<span data-value="0.30-0.39">0.30</span>',
	                    '<span data-value="0.40-0.49">0.40</span>',
	                    '<span data-value="0.50-0.69">0.50</span>',
	                    '<span data-value="0.70-0.99">0.70</span>',
	                    '<span data-value="1.00-1.99">1.00</span>',
	                '</div>'   
				].join('');
				$("#weight_box").after(size);

			}else if(TYPE==3){
				var jsonType=inlay;
			}else if(TYPE==4){
				var jsonType=gem;
			}else if(TYPE==5){
				var jsonType=emerald;
			}else if(TYPE==6){
				var jsonType=prime_gold;
				$("#Color_box").hide();
			}else if(TYPE ==7){
                var jsonType=inlaysetting;
                $("#Color_box").hide();
                $("#CertNo_div").hide();
                $("#OriginSN_div").hide();

			}
			//颜色
			var $color='<option value="">' + _("颜色") + '</option>';
			if(TYPE==3){
				for(var i=0;i<jsonType.length;i++){					
					if(jsonType[i].MainColor){						
						for(var j=0;j<jsonType[i].MainColor.length;j++){
							$color += '<option value="'+jsonType[i].MainColor[j][0]+'">'+ _(jsonType[i].MainColor[j][1]) +'</option>';
						}
					}
				}
			}else{
				for(var i=0;i<jsonType.length;i++){
					if(jsonType[i].Color){
						for(var j=0;j<jsonType[i].Color.length;j++){
							$color += '<option value="'+jsonType[i].Color[j][0]+'">'+ _(jsonType[i].Color[j][1]) +'</option>';
						}
					}
				}				
			}
			$("#_Color").html($color);
			var $Clarity="";
			if(TYPE==3){
				$Clarity+='<div class="term clarity" id="Clarity"><h4>'+_("主石净度")+'</h4><select id="Clarity_data" name="Clarity"><option value="">' + _("净度") + '</option>';
				if(jsonType[2].MainClarity){
					for(var j=0;j<jsonType[2].MainClarity.length;j++){
						$Clarity += '<option value="'+jsonType[2].MainClarity[j][0]+'">'+ _(jsonType[2].MainClarity[j][1]) +'</option>';
					}
				}
				$Clarity+="</select></div>";	
			}else if(TYPE==1 || TYPE==2){
				$Clarity+='<div class="term clarity" id="Clarity"><h4>'+_("净度")+'</h4><select id="Clarity_data" name="Clarity"><option value="">' + _("净度") + '</option>';
				if(jsonType[1].Clarity){
					for(var j=0;j<jsonType[1].Clarity.length;j++){
						$Clarity += '<option value="'+jsonType[1].Clarity[j][0]+'">'+ _(jsonType[1].Clarity[j][1]) +'</option>';
					}
				}
				$Clarity+="</select></div>";	
			}			
			$("#Color_box").after($Clarity);
			//所在地
			if(TYPE==1){
				var html_Place='<div class="term"><h4>'+_("所在地")+'</h4><select class="form-control list_search" name="Place" id="_Place"><option value="">' + _("所在地") + '</option>';							
				for(var i = 0; i < jsonType[0].Place.length; i++) {
					html_Place += '<option value="' + jsonType[0].Place[i][0] + '">' + _(jsonType[0].Place[i][1]) + '</option>';
				}		
				html_Place +='</select>';
				$("#Clarity").after(html_Place);
			}


			myApp.hideIndicator();
		},
	}
	orderFilter.init();
})();
//去掉首尾空格
function trimStr(str){
	return str.replace(/(^\s*)|(\s*$)/g,"");
}
//去掉数组里的空值
Array.prototype.clean = function(deleteValue) {  
  for (var i = 0; i < this.length; i++) {  
    if (this[i] == deleteValue) {           
      this.splice(i, 1);//返回指定的元素  
      i--;  
    }  
  }  
  return this;  
};  
 //业务列表
 function SalesLoad(){ 
            
     var requestSales={};

     //业务员3
     if(RoleID == 3)
     {
         requestSales.UserID = UserID;
     }

     requestSales.SysStatus = 1;//正常的团队 10-28

     $.ajax({
         url: "/Team/GetSaleList",//提交地址
         type: "POST",//提交方式
         data: JSON.stringify(requestSales),
         contentType: "application/json; charset=utf-8",
         success: function (result) {
             var _result = eval('(' + result + ')');//eval()解析单个json对象   

             if(_result.msgcode == false){

                 var options_sales = "";
                 options_sales += '<option value="">' + _(_result.msginfo) + '</option>';
                 $("#_salesUserID").html("");
                 $("#_salesUserID").html(options_sales);    
                        
             }else{

                 var options_sales = "";
                 options_sales += '<option value="">'+_("业务")+'</option>';
                 for (var i = 0; i < _result.length; i++) {
                     options_sales += '<option value="' + _result[i].UserID + '"  >' + _result[i].RealName + '</option>';
                 }
                 $("#_salesUserID").html("");
                 $("#_salesUserID").html(options_sales); 
             }
         }
     });
 }
  //采购列表
 function PurchasesLoad(){   
            
     var requestPurchases={};

     //采购4
     if(RoleID == 4)
     {
         requestPurchases.UserID = UserID;
     }

     requestPurchases.SysStatus = 1;//正常的团队 10-28

     $.ajax({
         url: "/Team/GetPurchaseList",//提交地址
         type: "POST",//提交方式
         data: JSON.stringify(requestPurchases),
         contentType: "application/json; charset=utf-8",
         success: function (result) {
             var _result = eval('(' + result + ')');//eval()解析单个json对象

             if(_result.msgcode == false){
                 var options_purchases = "";
                 options_purchases += '<option value=""  >' + _(_result.msginfo)+ '</option>';
                 $("#_purchaseUserIDs").html("");
                 $("#_purchaseUserIDs").html(options_purchases);
                       
             }else{

                 var options_purchases = "";
                 options_purchases += '<option value="">'+_("采购")+'</option>';
                 for (var i = 0; i < _result.length; i++) {
                     options_purchases += '<option value="' + _result[i].UserID + '"  >' + _result[i].RealName + '</option>';
                 }
                 $("#_purchaseUserIDs").html("");
                 $("#_purchaseUserIDs").html(options_purchases);
             }
                   
         }
     });
 }        
   
 //订单状态个数统计（公用8-25）
function LoadOrderStatusNumber() {
	$("#status1").text(0);//订单
    $("#status2").text(0);//订单
    $("#status3").text(0);//订单
    $("#status4").text(0);//订单
    $("#status5").text(0);//订单
    $("#status6").text(0);//订单
    $("#status7").text(0);//订单
    $("#status0").text(0);//订单总数
    var requestOrder = {};

    requestOrder.UserID=UserID;
    //业务3
    if(RoleID == 3 || RoleID == 6){
        requestOrder.SalesUserID = UserID;
    }

    //采购4
    if(RoleID == 4){
        requestOrder.PurchaseUserID = UserID;
	} 
	var p={}; 
	if(TYPE==1){
		var submitUrl="/Team/OrderNumber";
	}else if(TYPE==2){
		var submitUrl="/Team/GetOrderNewNumber";
		p.GoodsType=2;
		requestOrder.GoodsType=2;
	}else if(TYPE==3){
		var submitUrl="/Team/GetOrderNewNumber";
		p.GoodsType=3;
		requestOrder.GoodsType=3;
	}else if(TYPE==4){
		var submitUrl="/Team/GetOrderNewNumber";
		p.GoodsType=4;
        requestOrder.GoodsType=4;
	}else if(TYPE==5){
		var submitUrl="/Team/GetOrderNewNumber";
		p.GoodsType=5;
        requestOrder.GoodsType=5;
	}else if(TYPE==6){
		var submitUrl="/Team/GetOrderNewNumber";
		p.GoodsType=6;
        requestOrder.GoodsType=6;
	}else if(TYPE == 7){
        var submitUrl="/Team/GetOrderNewNumber";
        p.GoodsType=7;
        requestOrder.GoodsType=7;
	}
    $.ajax({
        url: submitUrl,//提交地址
        type: "POST",//提交方式
        data: JSON.stringify(requestOrder),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            var total = 0;

            if(_result.msgcode == false){

                $("#status1").html(0);//订单
                $("#status2").html(0);//订单
                $("#status3").html(0);//订单
                $("#status4").html(0);//订单
                $("#status5").html(0);//订单
                $("#status6").html(0);//订单
                $("#status7").html(0);//订单
                $("#status0").html(0);//订单总数

            }else{
                _result=_result.msginfo;
                for (var i = 0; i < _result.length; i++) {
                    if (_result[i].OrderStatus == 1) {//待采购
                        $("#status1").text(_result[i].Number);
                        total += _result[i].Number;
                    }
                    if (_result[i].OrderStatus == 2) {//待到货
                        $("#status2").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    }
                    if (_result[i].OrderStatus == 3) {//待出货
                        $("#status3").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    } 
                    if (_result[i].OrderStatus == 4) {//已出货
                        $("#status4").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    } 
                    if (_result[i].OrderStatus == 5) {//已作废
                        $("#status5").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    }
                    if (_result[i].OrderStatus == 6) {//已自留
                        $("#status6").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    }
                    if (_result[i].OrderStatus == 7) {//已退回
                        $("#status7").text(_result[i].Number);//订单
                        total += _result[i].Number;
                    }
                    $("#status0").text(total);//订单总数
				}
				
				//統計刪除數據
				// p.OrderStatus=0;
                // $.ajax({
                //     url: "/Team/GetOrderNewList", //提交地址
                //     type: "POST", //提交方式
                //     data: JSON.stringify(p),
                //     contentType: "application/json; charset=utf-8",
                //     success: function(result) {
                //         var _result=JSON.parse(result);
                //         _result=_result.msginfo;
                //         var num=0;
                //         for(var i=0;i<_result.length;i++){
                //             var dataStatus=_result[i].OrderStatus;
                //             // console.log(dataStatus)
                //             if(dataStatus===-1){
                //                 num+=1
                //             }
				// 		}
					
                //         if(TYPE==1){
                //         	$("#status0").html(total); //订单总数 全部
				// 		}else{
                //             $("#status0").html(total+num);
				// 		}
                //     }
                // });
            }
        }
    });
}

//裸钻订单颜色、净度搜索
function searchDiaParm() {
    //颜色
    var html_Color = '<option value="">' + _("颜色") + '</option>';
    for (var i = 0; i < stock[0].Color.length; i++) {
        html_Color += '<option value="' + stock[0].Color[i][0] + '">' + _(stock[0].Color[i][1]) + '</option>';
    }
    for (var i = 0; i < stock[1].Color.length; i++) {
        html_Color += '<option value="' + stock[1].Color[i][0] + '">' + _(stock[1].Color[i][1]) + '</option>';
    }
    $("#_Color").html(html_Color);


    //货品状态
    var html_Status = '<option value="">' + _("货品状态") + '</option>';
    for (var i = 0; i < stock[0].Status.length; i++) {
        html_Status += '<option value="' + stock[0].Status[i][0] + '">' + _(stock[0].Status[i][1]) + '</option>';
    }
    $("#_Status").html(html_Status);
}